﻿using Elastic.Clients.Elasticsearch;

public class MyDoc
{
    public int Id { get; set; }

    public string? User { get; set; }

    public string? Message { get; set; }
}

class Program
{
    private static string indexName = "mixing_process";

    static async Task Main(string[] args)
    {
        var client = new ElasticsearchClient(new Uri("http://admin:admin@172.18.64.150:65533"));
        var hasIndex = await client.Indices.ExistsAsync(indexName);

        if (hasIndex.Exists)
            await client.Indices.CreateAsync(indexName);

        var doc = new MyDoc
        {
            Id = 1,
            User = "flobernd",
            Message = "Trying out the client, so far so good?"
        };

        IndexResponse? response =  await client.IndexAsync(doc, indexName);
    }
}
